#ifndef CLOCK_CALENDAR_HPP
#define CLOCK_CALENDAR_HPP

#include <cpp3ds/Graphics/Drawable.hpp>
#include <cpp3ds/Graphics/Text.hpp>
#include <cpp3ds/Window/Event.hpp>
#include <cpp3ds/System/Clock.hpp>
#include "TweenObjects.hpp"
#include "CalendarBlock.hpp"
#include <TweenEngine/Tween.h>
#include <TweenEngine/TweenManager.h>
#include <memory>
#include <time.h>
#ifndef EMULATION
#include <3ds.h>
#endif

namespace Clock {

class Calendar : public cpp3ds::Drawable, public util3ds::TweenTransformable<cpp3ds::Transformable> {
public:
	void update(float delta);
	void processEvent(const cpp3ds::Event& event);

	Calendar();
	~Calendar();

	void init(struct tm * timeinfo);

	void previous();
	void next();
	void previousYear();
	void nextYear();

protected:
	virtual void draw(cpp3ds::RenderTarget& target, cpp3ds::RenderStates states) const;

private:
	util3ds::TweenRectangleShape m_calendarDial;
	std::vector<std::shared_ptr<CalendarBlock>> m_calendarBlocks;

	util3ds::TweenRectangleShape m_calendarMonthYear;
	util3ds::TweenText m_textMonthYear;

	util3ds::TweenText m_textLButton;
	util3ds::TweenText m_textRButton;

	struct tm m_loadedTimeinfo;

	int m_previousDay;
	int m_actualDay;

	bool m_checkButtons;
	bool m_startedRepeat;
	cpp3ds::Clock m_clockButtonCheck;

	cpp3ds::Clock m_updateClock;

	TweenEngine::TweenManager m_tweenManager;

};

} // namespace Clock

#endif // CLOCK_CALENDAR_HPP
